package com.shimao.celnet.payment.quartz;

import com.shimao.celnet.payment.model.PPayCUPUser;
import com.shimao.celnet.payment.service.PPayCupUserService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.List;

/**删除无效数据
 * Created by XSW on 2018/11/12.
 */
public class DeleteInvalidData  {

    protected Logger logger = Logger.getLogger(this.getClass());

    @Autowired
    private PPayCupUserService pPayCupUserService;

    @Scheduled(cron = "0 53 16 * * ?")
    public void DeleteInvalidData()  {
        try {
            //1、查询银联注册表，并获取list集合
            List<PPayCUPUser> list = pPayCupUserService.findInvalidCUPUsers();
            logger.info("银联无效数据："+list.size());
            //2、如果集合不是空
            if (list != null && list.size() > 0){
                //3、遍历集合并根据主键进行删除
                for (PPayCUPUser p:list){
                    pPayCupUserService.delete(p.getGuid());
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
